home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / jbanner2.zip / BANNER.ZIP / SCRL.ASM < prev    next >
Assembly Source File  |  1986-12-04  |  13KB  |  369 lines

  1. page,132
  2. title SCROLLA  *** Scroll Display Adapter Horiz or Vert
  3. comment * ===============================================================
  4.  
  5. 05-06-86
  6. Thomas E. Link  Original Submission to IBMSIG
  7.  
  8. MODIFIED FOR CLIPPER BY RE MCCORD  10-21-86
  9.         This is a procedure for display scrolling.
  10.         It will support any BIOS supported adapter for
  11.         vertical scrolling, and text modes for horizontal scrolling.
  12.         Found in public domain and all alterations remain in the
  13.         public domain 10-21-86
  14.  
  15. USAGE IS AS FOLLOWS:
  16.  
  17. BASIC Compiler:
  18.  
  19.         10 call scroll(dir%,car%,ulr%,ulc%,lrr%,lrc%,att%)
  20.  
  21. PASCAL     declare as:
  22.        procedure scroll(dir,car,ulr,ulc,lrr,lrc,att: integer);extern;
  23.            use as:
  24.        scroll(1,2,0,0,24,79,7);
  25.        This example will scroll right the entire screen two characters
  26.        with fill attribute 7 (white on black).
  27.  
  28. LATTICE C
  29.           use as:
  30.        scroll(2,3,0,0,4,4,0x78);
  31.        This example will scroll right the upper left 5x5 characters of
  32.        the screen 3 characters with fill attribute hex 78(grey on white).
  33.  
  34. CLIPPER
  35.               use as:
  36.         CALL  ASCROLL WITH DIR,CAR,ATT,ULR,ULC,LRR,LRC
  37.         THIS MUST BE PASSED AS CHARACTORS
  38.         ie> CHR(nn)
  39.         Order= direction up/down 6,7  left right 1,2
  40.         Attributes are decimal eqivalents of Hex attribute
  41.         01234567ABCDEF
  42.         ||           | 
  43.         | Blue.......|
  44.         Black        High White
  45.         e.g. Hex 1F = decimal 31 call with chr(31)
  46.              Blue background,High white foreground
  47.   
  48.   The three equates below allow custom tailoring before assembling.
  49.   Place a `;' before the statement and it becomes a comment (not defined)
  50.   This allows usage with various languages and display adapters.
  51.  
  52.   BASIC creates code compatible with compiled or interpretive BASIC.
  53.   Otherwise code will be for IBM PASCAL.
  54.  
  55.   BLOAD will build a header onto the code to allow the .BIN file to be
  56.   directly BLOADed by BASIC.
  57.  
  58.   FLASH determines whether there will be a flash of the color display
  59.   during a scroll. If not true, you get snow on an IBM color display.
  60.  
  61.   LATTICE will create an object code file compatible with the Lattice
  62.   C Compiler small molule, else code will be for IBM PASCAL.
  63.  
  64. ======================================================================= *
  65.  
  66.  
  67. ; The equates as listed below create a BASIC BLOAD file.
  68. ; BASIC    equ  1        ; Use with any version BASIC  else PASCAL
  69. ; BLOAD    equ  1        ; Makes the .BIN file directly BASIC BLOADable  
  70. CLIPPER    EQU  1        ; ASM FOR CLIPPER ;*************************
  71.  FLASH    equ  1        ; Leaving this equate makes scroll flash like IBM
  72. ;LATTICE  equ  1        ; Creates code compatible with LATTICE small mod.
  73.  
  74. bios_data       segment at 40H  ; This is where the IBM PC stores various
  75. org     49H                             ; operating parameters for the
  76.         crt_mode        db      ?       ; display (0040:0049H).
  77.         crt_cols        dw      ?
  78.         crt_len         dw      ?
  79.         crt_start       dw      ?
  80.         cursor_posn     dw      8 dup(?)
  81.         cursor_mode     dw      ?
  82.         active_page     db      ?
  83.         addr_6845       dw      ?
  84.         crt_mode_set    db      ?
  85. bios_data       ends
  86.  
  87. IFDEF LATTICE                   ; This is the entry status of the stack
  88.   stackin struc                 ; with LATTICE C small module
  89.         pushed_bp       dw      ?      
  90.         ret_addr        dw      ?
  91.         dir             dw      ?
  92.         car             dw      ?
  93.         ulr             dw      ?
  94.         ulc             dw      ?
  95.         lrr             dw      ?
  96.         lrc             dw      ?
  97.         att             dw      ?
  98.   stackin ends
  99.  
  100. ENDIF
  101. IFDEF BASIC
  102.  
  103.   stackin struc                ; This is the entry status with PASCAL
  104.         pushed_bp       dw      ?       ; or BASIC
  105.         ret_addr        dd      ?
  106.         att             dw      ?
  107.         lrc             dw      ?
  108.         lrr             dw      ?
  109.         ulc             dw      ?
  110.         ulr             dw      ?
  111.         car             dw      ?
  112.         dir             dw      ?
  113.   stackin ends
  114.  
  115. ENDIF
  116.  
  117. DATA    SEGMENT PUBLIC 'DATA'   ; define a dummy data segment
  118. DATA    ENDS
  119. DGROUP  GROUP   DATA
  120.  
  121. IFDEF LATTICE
  122.  
  123.     ret_len equ 0
  124.     PGROUP      GROUP   PROG
  125.     SCROLLS     segment public 'PROG'
  126.     assume      cs:PGROUP,ds:bios_data
  127.                 public  SCROLL,SCROLL_,_SCROLL
  128.     SCROLL_:
  129.     _SCROLL:
  130.     SCROLL      proc    near
  131.  
  132. ENDIF 
  133. IFDEF  BASIC   ; PASCAL-BASIC VERSION
  134.  
  135.     ret_len equ type stackin - 6
  136.     SCROLLS     segment 'CODE'
  137. ifdef   BLOAD
  138.         db      0FDH            ; indicate BLOAD file
  139.         dw      0               ; segment - BASIC uses default
  140.         dw      0               ; offset - spec in BLOAD
  141.         dw      scrollend-scroll; length of routine
  142. endif
  143.     assume      cs:SCROLLS,ds:bios_data
  144.                 public  SCROLL
  145.     SCROLL      proc    far
  146.  
  147. ENDIF
  148.  IFDEF   CLIPPER
  149.   RET_LEN  EQU   0
  150.          SCROLLS  SEGMENT PUBLIC 'CODE'
  151.         PUBLIC ASCROLL
  152.  ASCROLL    PROC    FAR        ;SAVE DS
  153.          ASSUME CS:SCROLLS
  154.         PUSH    DS
  155.         CALL   SCROLL
  156.         POP     DS      ;RESET DS
  157.         RET
  158. ASCROLL ENDP
  159.  
  160.          SCROLL  PROC   NEAR
  161.          ASSUME DS:BIOS_DATA
  162.  ENDIF
  163.  
  164. ;........................................................................
  165.         push    bp
  166.         mov     bp,sp
  167.  
  168. ifdef   BASIC
  169.         mov     si,[bp].dir             ; Get parms off stack
  170.         mov     ah,[si]
  171.         mov     si,[bp].car
  172.         mov     al,[si]
  173.         mov     si,[bp].att
  174.         mov     bh,[si]
  175.         mov     si,[bp].ulr
  176.         mov     ch,[si]
  177.         mov     si,[bp].ulc
  178.         mov     cl,[si]
  179.         mov     si,[bp].lrr
  180.         mov     dh,[si]
  181.         mov     si,[bp].lrc
  182.         mov     dl,[si]
  183. ENDIF
  184. IFDEF  LATTICE
  185.         mov     ah,byte ptr[bp].dir     ; Get parms off stack
  186.         mov     al,byte ptr[bp].car
  187.         mov     bh,byte ptr[bp].att
  188.         mov     ch,byte ptr[bp].ulr
  189.         mov     cl,byte ptr[bp].ulc
  190.         mov     dh,byte ptr[bp].lrr
  191.         mov     dl,byte ptr[bp].lrc
  192. endif         
  193. IFDEF  CLIPPER
  194.        
  195.                                         ;GET PARMS OFF STACK
  196.         MOV     AX,BP
  197.         ADD     AX,04H
  198.         MOV     BP,AX
  199.         LES     SI,SS:[BP+6]
  200.         MOV     AH,BYTE PTR ES:[SI]       ;DIR
  201.         LES     SI,SS:[BP+10]
  202.         MOV     AL,BYTE PTR ES:[SI]       ;CAR
  203.         LES     SI,SS:[BP+14]
  204.         MOV     BH,BYTE PTR ES:[SI]       ;ATT
  205.         LES     SI,SS:[BP+18]
  206.         MOV     CH,BYTE PTR ES:[SI]       ;ULR
  207.         LES     SI,SS:[BP+22]
  208.         MOV     CL,BYTE PTR ES:[SI]       ;ULC
  209.         LES     SI,SS:[BP+26]
  210.         MOV     DH,BYTE PTR ES:[SI]       ;LRR
  211.         LES     SI,SS:[BP+30]
  212.         MOV     DL,BYTE PTR ES:[SI]       ;LRC
  213. ENDIF
  214.         cmp     ah,6            ; If direction is 6(up) or 7 (down)
  215.         je      use_BIOS        ;    then use BIOS
  216.         cmp     ah,7         
  217.         jne     use_toms
  218. use_BIOS:
  219.         int     10h
  220. nop_exit:
  221.         pop     bp
  222.         ret     ret_len
  223. use_toms:
  224.         cmp     ah,1            ; If direction is 1 (left)
  225.         je      ut1
  226.         cmp     ah,2            ;  or 2 (right)
  227.         jne     nop_exit
  228. ut1:
  229.         push    ds              ; continue ...
  230.         push    es
  231.         push    ax
  232.         mov     ax,bios_data    ; We need to find out video mode.
  233.         mov     ds,ax           ; Stored in BIOS_DATA
  234.         mov     ax,0B800h       ; Get segment address of color-graphics
  235.         cmp     crt_mode,4      ; Jump if color card text modes.
  236.         jb      color_kill
  237.         mov     ax,0B000h       ; Segment for mono card.
  238.         cmp     crt_mode,7      ; Is this MONO mode ?
  239.         je      set_seg         ; Yes - continue with mono segment set.
  240.         jmp     scroll_return   ; We are in a graphics mode - exit.
  241.         cli
  242. color_kill:
  243. IFDEF   FLASH                   ; If flash is ok then .....
  244.         push    ax
  245.         push    dx
  246.         mov     dx,3DAh         ; Put status port into DX.
  247. ck1:
  248.         in      al,dx           ; Test for vertical retrace
  249.         test    al,8
  250.         jz      ck1             ; Loop until OK
  251.         mov     al,25h          ; Value to kill color display.
  252.         mov     dx,03D8h
  253.         out     dx,al           ; Output to color mode port.
  254.         pop     dx
  255.         pop     ax
  256. ENDIF
  257.  
  258. set_seg:
  259.         mov     es,ax
  260.         pop     ax
  261.         cmp     ah,1
  262.         je      scroll_left
  263.         jmp     scroll_right
  264. ;.........................
  265. scroll_left     proc    near
  266.         cld                     ; Insure incrementing
  267.         mov     bl,al           ; AL has number of columns to scroll.
  268.                                 ; Save it in BL
  269.                                 ; (BH has attribute).
  270.         mov     ax,cx           ; CX contains the upper left corner.
  271.         call    scroll_position ; Do setup for scroll.
  272.         add     si,ax           ; From address
  273.         mov     ah,dh           ; # of rows in block.
  274. row_loop:       ;---------------- Move loop
  275.         call    m_row           ; Move one row.
  276.         add     si,bp
  277.         add     di,bp           ; Point to next line in block,
  278.         dec     ah              ;       decrement the number of rows
  279.         jnz     row_loop        ;       and loop if not finished.
  280.         jmp     scroll_return   ; Exit this procedure.
  281. scroll_left     endp
  282.  
  283. ;------------------
  284. scroll_position proc    near
  285.         push    bx              ; Save BX.
  286.         mov     bx,ax
  287.         mov     al,ah           ; Move number of rows to AL.
  288.         mul     byte ptr crt_cols ; Multiply by number of bytes to a row.
  289.         xor     bh,bh
  290.         add     ax,bx           ; Add in column value.
  291.         sal     ax,1            ; x 2 for attribute bytes.
  292.         add     ax,crt_start    ; Offset of active page.
  293.         pop     bx              ; Restore BX
  294.         mov     di,ax           ; Address to move TO.
  295.         mov     si,ax           ; Address to move FROM.
  296.         sub     dx,cx           ; DX = #rows,#cols in block
  297.         inc     dh              ; Increment to include row
  298.         inc     dl              ;                      and column zero.
  299.         xor     ch,ch
  300.         xor     ah,ah           ; Clear out CH and AH.
  301.         mov     bp,crt_cols     ; Get number of columns in display.
  302.         add     bp,bp           ; Times 2 for attribute byte.
  303.         mov     al,bl           ; Get column count.
  304.         shl     al,1            ; Times 2 for attribute byte.
  305.         push    es              ; Get ES into DS.
  306.         pop     ds
  307.         ret
  308. scroll_position endp
  309.  
  310. ;------------------
  311. m_row   proc    near            ; Move one row
  312.         push    ax
  313.         push    si              ; Save registers.
  314.         push    di
  315.         mov     cl,dl           ; # of columns in block in CL.
  316.         sub     cl,bl           ; # of columns to be moved.
  317.         rep     movsw           ; move
  318.         mov     cl,bl           ; get # of columns to clear in cl.
  319.         mov     ah,bh           ; Get attribute into AH.
  320.         mov     al,' '          ; and a space character into AL.
  321.         rep     stosw           ; Store it.
  322.         pop     di
  323.         pop     si              ; restore registers ...
  324.         pop     ax
  325.         ret                     ; ... and return.
  326. m_row   endp
  327.  
  328. ;------------------
  329. scroll_right    proc    near
  330.         std                     ; Set direction flag to decrement.
  331.         mov     bl,al           ; Move line count into BL.
  332.                                 ; BH has fill attribute.
  333.         mov     ax,dx           ; Move lower right corner into AX.
  334.         call    scroll_position ; Get regen location.
  335.         sub     si,ax           ; Si is pointer to FROM location.
  336.         mov     ah,dh           ; Get total # of rows.
  337. r_loop:
  338.         call    m_row           ; Move one row.
  339.         sub     si,bp           ; Set pointers to point at next row.
  340.         sub     di,bp
  341.         dec     ah              ; Decrement rows left to move.
  342.         jnz     r_loop          ; Loop if not finished.
  343. scroll_right    endp
  344.  
  345. ;----------------------------
  346.  
  347. scroll_return:
  348.         cld                     ; Restore direction flag.
  349.         sti                     ; Restore interrupt flag.
  350. IFDEF   FLASH                   ; If flash is ok
  351.         mov     ax,bios_data
  352.         mov     ds,ax
  353.         cmp     crt_mode,7      ; Is this the mono mode ?
  354.         je      not_color       ; Yes - skip video reset
  355.         mov     al,crt_mode_set ; Get stored mode
  356.         mov     dx,03d8h
  357.         out     dx,al           ; Output to color card mode port.
  358. not_color:
  359. ENDIF
  360.         pop     es
  361.         pop     ds
  362.         pop     bp
  363.         ret     ret_len          ; return.
  364. SCROLL  endp
  365. scrollend       equ     $
  366. SCROLLS ends
  367. end
  368.  
  369.